/* @(#)DecKanGlImageManager.java
 ** 
** Copyright (C) 2001-2011 by Steven D. Stamps
**
**             Trademarks & Copyrights
** Flywheel Management Science(TM) and FlywheelMS(TM) are exclusive
** trademarks of Steven D. Stamps and may only be used freely for
** the purpose of identifying the unforked version of this software.
** Subsequent forks (if any) may not use these trademarks.  All other
** rights are reserved.
**
** DecKanGL (Decorated Kanban Glyph Language) and TribKn (Tribal Knowledge)
** are also exclusive trademarks of Steven D. Stamps.  These may be used
** freely within the unforked FlywheelMS application and documentation.
** All other rights are reserved.
**
** Trademark information is available at
** <http://www.flywheelms.org/trademarks>
**
** Flywheel Management Science(TM) is a copyrighted body of management
** metaphors, governance processes, and leadership techniques that is
** owned by Steven D. Stamps.  These copyrighted materials may be freely
** used, without alteration, by the community (users and developers)
** surrounding this GPL3-licensed software.  Additional copyright
** information is available at <http://www.flywheelms.org/copyrights>
**
**              GPL3 Software License
** This program is free software: you can use it, redistribute it and/or
** modify it under the terms of the GNU General Public License, version 3,
** as published by the Free Software Foundation. This program is distributed
** in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
** even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
** PURPOSE.  See the GNU General Public License for more details. You should
** have received a copy of the GNU General Public License, in a file named
** COPYING, along with this program.  If you cannot find your copy, see
** <http://www.gnu.org/licenses/gpl-3.0.html>.
*/
package com.fmscorp.deckangl.core;

import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.logging.Logger;

import javax.swing.ImageIcon;



/**
 * @author sstamps
 */
public class DecKanGlImageManager extends CoreImageManager {
	
	private static final String JAR_FILE_SEPARATOR = "/";

	public static final String directory_path_DecKanGL = JAR_FILE_SEPARATOR + "DecKanGL" + JAR_FILE_SEPARATOR;
	public static final String directory_path_STATUS = directory_path_DecKanGL + "Status" + JAR_FILE_SEPARATOR;
	public static final String directory_path_NOUN = directory_path_DecKanGL + "Noun" + JAR_FILE_SEPARATOR;
  
    public static final String icon_path_DECKANGL_DICTIONARY = directory_path_DecKanGL + "decKanGl.png";

    public static final String icon_path_DECKANGL_STATUS_GRAY = directory_path_STATUS + "Status-Gray.png";
    public static final String icon_path_DECKANGL_STATUS_GREEN = directory_path_STATUS + "Status-Green.png";
    public static final String icon_path_DECKANGL_STATUS_PINK = directory_path_STATUS + "Status-Pink.png";
    public static final String icon_path_DECKANGL_STATUS_YELLOW = directory_path_STATUS + "Status-Yellow.png";
    
    public static final String icon_path_DECORATOR_TRANSPARENT = "";  // DecKanGl knows not to paint this.
    
    public static final String directory_path_DECORATOR = directory_path_DecKanGL + "Decorator" + JAR_FILE_SEPARATOR;
    public static final String directory_path_DECORATOR_LEFT_ZONE_CORNER = directory_path_DECORATOR + "LeftZoneCorner" + JAR_FILE_SEPARATOR;
    public static final String directory_path_DECORATOR_LEFT_ZONE_MIDDLE = directory_path_DECORATOR + "LeftZoneMiddle" + JAR_FILE_SEPARATOR;
    public static final String directory_path_DECORATOR_RIGHT_ZONE_CORNER = directory_path_DECORATOR + "RightZoneCorner" + JAR_FILE_SEPARATOR;
    public static final String directory_path_DECORATOR_RIGHT_ZONE_MIDDLE = directory_path_DECORATOR + "RightZoneMiddle" + JAR_FILE_SEPARATOR;
    public static final String directory_path_DECORATOR_BOTTOM_ZONE = directory_path_DECORATOR + "BottomZone" + JAR_FILE_SEPARATOR;
    public static final String directory_path_DECORATOR_TOP_ZONE = directory_path_DECORATOR + "TopZone" + JAR_FILE_SEPARATOR;

    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_BLUE = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Blue.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_DISABLED = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Disabled.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_GRAY = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Gray.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_GREEN = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Green.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_MAGENTA = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Magenta.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_ORANGE = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Orange.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_RED = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Red.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_LEFT_YELLOW = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Yellow.png";

    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_BLUE = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Blue.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_DISABLED = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Disabled.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_GRAY = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Gray.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_GREEN = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Green.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_MAGENTA = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Magenta.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_ORANGE = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Orange.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_RED = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Red.png";
    public static final String icon_path_DECORATOR_BOTTOM_ZONE_RIGHT_YELLOW = directory_path_DECORATOR_BOTTOM_ZONE + "DecoratorBottomZone-Yellow.png";

    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_BLUE = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Blue.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_DISABLED = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Disabled.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_GRAY = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Gray.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_GREEN = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Green.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_MAGENTA = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Magenta.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_ORANGE = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Orange.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_RED = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Red.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_BOTTOM_YELLOW = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Yellow.png";

    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_BLUE = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Blue.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_DISABLED = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Disabled.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_GRAY = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Gray.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_GREEN = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Green.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_MAGENTA = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Magenta.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_ORANGE = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Orange.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_RED = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Red.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_MIDDLE_YELLOW = directory_path_DECORATOR_LEFT_ZONE_MIDDLE + "DecoratorLeftZoneMiddle-Yellow.png";

    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_BLUE = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Blue.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_DISABLED = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Disabled.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_GRAY = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Gray.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_GREEN = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Green.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_MAGENTA = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Magenta.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_ORANGE = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Orange.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_RED = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Red.png";
    public static final String icon_path_DECORATOR_LEFT_ZONE_TOP_YELLOW = directory_path_DECORATOR_LEFT_ZONE_CORNER + "DecoratorLeftZoneCorner-Yellow.png";

    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_BLUE = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Blue.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_DISABLED = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Disabled.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_GRAY = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Gray.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_GREEN = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Green.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_MAGENTA = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Magenta.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_ORANGE = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Orange.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_RED = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Red.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_BOTTOM_YELLOW = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Yellow.png";
    
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_BLUE = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Blue.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_DISABLED = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Disabled.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_GRAY = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Gray.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_GREEN = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Green.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_MAGENTA = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Magenta.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_ORANGE = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Orange.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_RED = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Red.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_MIDDLE_YELLOW = directory_path_DECORATOR_RIGHT_ZONE_MIDDLE + "DecoratorRightZoneMiddle-Yellow.png";

    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_BLUE = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Blue.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_DISABLED = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Disabled.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_GRAY = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Gray.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_GREEN = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Green.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_MAGENTA = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Magenta.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_ORANGE = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Orange.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_RED = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Red.png";
    public static final String icon_path_DECORATOR_RIGHT_ZONE_TOP_YELLOW = directory_path_DECORATOR_RIGHT_ZONE_CORNER + "DecoratorRightZoneCorner-Yellow.png";

    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_BLUE = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Blue.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_DISABLED = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Disabled.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_GRAY = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Gray.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_GREEN = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Green.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_MAGENTA = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Magenta.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_ORANGE = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Orange.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_RED = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Red.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_LEFT_YELLOW = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Yellow.png";

    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_BLUE = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Blue.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_DISABLED = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Disabled.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_GRAY = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Gray.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_GREEN = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Green.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_MAGENTA = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Magenta.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_ORANGE = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Orange.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_RED = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Red.png";
    public static final String icon_path_DECORATOR_TOP_ZONE_RIGHT_YELLOW = directory_path_DECORATOR_TOP_ZONE + "DecoratorTopZone-Yellow.png";

    //////////////////////////////////////////////////////////////////////////////////////////

    private static HashMap<String, ImageIcon> imageHashMap = new HashMap<String, ImageIcon>();
    private static final Logger LOGGER = Logger.getLogger(DecKanGlImageManager.class.getName());
//    static {
//    	ImageIcon theIconMissingImage = buildIconForMissingImage();
//    	imageHashMap.put(icon_MISSING_IMAGE, theIconMissingImage);
//    }
    
//    public static ImageIcon buildIconForMissingImage() {
//    	return imageHashMap.get(icon_ICON_MISSING);
//    }
    
    public static ImageIcon retrieveImageIconFromCache(String anImagePath) {
    	return (ImageIcon) imageHashMap.get(anImagePath);
    }

	public static void putImageIconIntoCache(String anImagePath,
			ImageIcon theImageIcon) {
		imageHashMap.put(anImagePath, theImageIcon);
	}
    
    public static ImageIcon retrieveImageIcon(String anImagePath) {
    	ImageIcon theImageIcon;
    	theImageIcon = (ImageIcon) imageHashMap.get(anImagePath);
    	if(theImageIcon == null){
    		theImageIcon = CoreImageManager.createImageIcon(DecKanGlImageManager.class.getResource(anImagePath));
        	if(theImageIcon == null){
//        		theImageIcon = (ImageIcon) imageHashMap.get(icon_ICON_MISSING);
        		LOGGER.severe("Warning:  Missing image.\n" + 
        				"    ImagePath:" + anImagePath + "\n");
        	}
        	else {
        		imageHashMap.put(anImagePath, theImageIcon);
        	}
    	}
    	if(theImageIcon == null) {
    		LOGGER.severe("Fatal error:  Cannot retrieve images.\n" + 
    				"    ImagePath:" + anImagePath + "\n" +
    				"    WorkingDirectory:" + new File(".").getAbsolutePath() + "\n" );
    	}
    	return theImageIcon;
    }
    
    public static URL getImageURL(String anImageName) {
        return DecKanGlImageManager.class.getResource(anImageName);
    }
    
//    public static Cursor createCustomCursor(String anImagePath) {
//        return
//            FlywheelMsApplication.getInstance().getMainFrame().getToolkit().createCustomCursor(
//                retrieveImageIcon(anImagePath).getImage(),
//                new Point(1, 1),
//                anImagePath);
//    }
    
}